package org.kzwl.book.controller.app;


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.kzwl.comm.pojo.ResponseData;
import org.kzwl.comm.pojo.bo.thear.GetRecordBO;
import org.kzwl.comm.pojo.bo.volunteers.RegisterVolunteersBO;
import org.kzwl.comm.pojo.bo.volunteers.VolunteersBasicBO;
import org.kzwl.comm.pojo.bo.volunteers.VolunteersSignBO;
import org.kzwl.comm.pojo.dto.volunteers.VolunteersDTO;
import org.kzwl.service.web.CuVolunteersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/app-cu-volunteers")
@Api("app志愿者服务")
public class AppVolunteersController {

    @Autowired
    CuVolunteersService cuVolunteersService;

    @ApiOperation(value = "志愿者信息基础查询", notes = "只需要填分页参数")
    @PostMapping("/queryBasic")
    public ResponseData<List<VolunteersDTO>> queryBasic(@RequestBody VolunteersBasicBO bo) {
        IPage<VolunteersDTO> page = cuVolunteersService.queryBasic(bo);
        return new ResponseData<>(page.getRecords());
    }

    @ApiOperation(value = "服务报名")
    @PostMapping("/volunteersSign")
    public ResponseData<Void> volunteersSign(@RequestBody VolunteersSignBO bo)
    {
        cuVolunteersService.volunteersSign(bo);
        return new ResponseData<>();
    }

    @ApiOperation(value = "志愿者记录")
    @PostMapping("/getRecord")
    public ResponseData<List<VolunteersDTO>> getRecord(@RequestBody GetRecordBO bo)
    {
        List<VolunteersDTO> list = cuVolunteersService.getRecord(bo);
        return new ResponseData<>(list);
    }


    @ApiOperation(value = "注册成为志愿者")
    @PostMapping("/registerVolunteers")
    public ResponseData<Void> registerVolunteers(@RequestBody RegisterVolunteersBO bo)
    {
        cuVolunteersService.registerVolunteers(bo);
        return new ResponseData<>();
    }

}
